package logic

import (
	"context"
	"user/userrpc/userrpc"

	"user/api/internal/svc"
	"user/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpdataLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUpdataLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdataLogic {
	return &UpdataLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UpdataLogic) Updata(req *types.UpdataRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	update, err := l.svcCtx.UserRpc.Update(l.ctx, &userrpc.UpdateRequest{})

	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	}
	//handler, err := pkg.TokenHandler(strconv.FormatInt(login.Id, 10))
	//if err != nil {
	//	return &types.Response{
	//		Message: err.Error(),
	//		Code:    500,
	//		Data:    nil,
	//	}, nil
	//}

	return &types.Response{
		Message: "修改成功",
		Code:    200,
		Data:    update,
	}, nil
}
